package com.lvan.rabbit.producer.mode5_routingtopic;

import com.lvan.rabbit.utils.RabbitMQUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**
 * @author Lvan
 */
public class RoutTopic1 {
    public static void main(String[] args) throws IOException {
        Connection connection = RabbitMQUtil.getConnection();
        Channel channel = connection.createChannel();
        // 声明交换机以及交换机类型
        channel.exchangeDeclare("topics", "topic");
        // 发布消息
        String routingKey = "user.info.lvan";
        channel.basicPublish("topics", routingKey, null, (routingKey + "This is topic message").getBytes());
        RabbitMQUtil.closeConnectionAndChanel(channel, connection);
    }
}
